package com.aifund.admin.controller;

import com.aifund.admin.entity.form.system_msg.AddSystemMsgForm;
import com.aifund.admin.entity.form.system_msg.EditSystemMsgForm;
import com.aifund.admin.entity.form.system_msg.SystemMsgPageForm;
import com.aifund.admin.entity.vo.PageResult;
import com.aifund.admin.service.SystemMsgService;
import com.aifund.common.entity.SystemMsg;
import com.aifund.common.result.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/systemMsg")
public class SystemMsgController {

    @Autowired
    SystemMsgService systemMsgService;



    @GetMapping("/systemMsgList")
    public PageResult<SystemMsg> systemMsgList(SystemMsgPageForm form){
        return systemMsgService.systemMsgList(form);
    }

    @PostMapping("/addSystemMsg")
    public ResultBody addSystemMsg(@Validated AddSystemMsgForm form){
         systemMsgService.addSystemMsg(form);
         return ResultBody.success();
    }

    @PostMapping("/editSystemMsg")
    public ResultBody editSystemMsg(@Validated EditSystemMsgForm form){
        systemMsgService.editSystemMsg(form);
        return ResultBody.success();
    }


    @PostMapping("/delSystemMsg")
    public ResultBody delSystemMsg(Long id){
        systemMsgService.delSystemMsg(id);
        return ResultBody.success();
    }

    @GetMapping("/getById")
    public ResultBody getById(Long id){
        return ResultBody.success(systemMsgService.getById(id));
    }



}
